package com.sharp.join.tk.mybatis.service;

import com.sharp.join.tk.mybatis.dao.entity.SchoolTeacherJoin;
import com.sharp.join.tk.mybatis.dao.mapper.SchoolTeacherJoinDao;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import javax.annotation.Resource;
import java.util.List;

/**
 * Title: SchoolTeacherJoinService
 * Description: Copyright: Copyright (c) 2019 Company: BHFAE
 *
 * @author Sharp
 * @date 2022/7/18 16:23
 */
@Service
public class SchoolTeacherJoinService {
    @Resource
    private SchoolTeacherJoinDao schoolTeacherJoinDao;

    public List<SchoolTeacherJoin> getSchoolTeacherJoinList(String schoolId, String classId, String teacherId) {
        Example example = new Example(SchoolTeacherJoin.class);
        Example.Criteria criteria = example.createCriteria();
        if (StringUtils.isNotEmpty(schoolId)) {
            criteria.andEqualTo("id", schoolId);
        }
        if (StringUtils.isNotEmpty(classId)) {
            criteria.andEqualTo("classTeacherJoinList.id", classId);
        }
        if (StringUtils.isNotEmpty(teacherId)) {
            criteria.andEqualTo("classTeacherJoinList.teacherList.id", teacherId);
        }
        return schoolTeacherJoinDao.joinSelectByExample(example);
    }

    public List<SchoolTeacherJoin> getSchoolTeacherJoinListByXml(String schoolId, String classId, String teacherId) {
        return schoolTeacherJoinDao.select(schoolId, classId, teacherId);
    }
}
